import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/Home'
import Detail from '@/pages/detail/Detail'
import DetailCount from '@/pages/detail/components/Count'
import DetailForecast from '@/pages/detail/components/Forecast'
import DetailAnalysis from '@/pages/detail/components/Analysis'
import DetailPublish from '@/pages/detail/components/Publish'

Vue.use(Router)

export default new Router({
  mode: 'history', // 去掉路由地址的#
  routes: [
    {
      path: '/',
      redirect: '/home'// 路由重定向
    },
    {
      path: '/home',
      name: 'Home',
      component: Home
    },
    {
      path: '/detail',
      name: 'Detail',
      component: Detail,
      redirect: '/detail/count',
      children: [ // 下的路由不能加/，否则会找到根目录
        {
          path: 'count',
          name: 'DetailCount',
          component: DetailCount
        },
        {
          path: 'forecast',
          name: 'DetailForecast',
          component: DetailForecast
        },
        {
          path: 'analysis',
          name: 'DetailAnalysis',
          component: DetailAnalysis
        },
        {
          path: 'publish',
          name: 'DetailPublish',
          component: DetailPublish
        }
      ]
    }
  ]
})
